package com.pcitc.app.model;

import com.pcitc.app.model.BaseObject;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;

import java.io.Serializable;

@Entity
@Table(name="TBL_POSITION",schema="XZGD")
public class TblPosition extends BaseObject implements Serializable {
    private Long pid;
    private String pname;
    private Long orgid;
    private Set<TblUserPosition> tblUserPositions = new HashSet<TblUserPosition>(0);
    private Set<TblPositionFunc> tblPositionFuncs = new HashSet<TblPositionFunc>(0);

    public TblPosition(){
    	
    }
    
    public TblPosition(final String pname){
    	this.pname = pname;
    }
    @Id  @GeneratedValue(strategy = GenerationType.AUTO)    
    public Long getPid() {
        return this.pid;
    }
    
    public void setPid(Long pid) {
        this.pid = pid;
    }
    
    @Column(name="PNAME", length=256)
    public String getPname() {
        return this.pname;
    }
    
    public void setPname(String pname) {
        this.pname = pname;
    }
    
    @Column(name="ORGID", precision=22, scale=0)
    public Long getOrgid() {
        return this.orgid;
    }
    
    public void setOrgid(Long orgid) {
        this.orgid = orgid;
    }
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="tblPosition")
    public Set<TblUserPosition> getTblUserPositions() {
        return this.tblUserPositions;
    }
    
    public void setTblUserPositions(Set<TblUserPosition> tblUserPositions) {
        this.tblUserPositions = tblUserPositions;
    }
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="tblPosition")
    public Set<TblPositionFunc> getTblPositionFuncs() {
        return this.tblPositionFuncs;
    }
    
    public void setTblPositionFuncs(Set<TblPositionFunc> tblPositionFuncs) {
        this.tblPositionFuncs = tblPositionFuncs;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        TblPosition pojo = (TblPosition) o;

        if (pname != null ? !pname.equals(pojo.pname) : pojo.pname != null) return false;
        if (orgid != null ? !orgid.equals(pojo.orgid) : pojo.orgid != null) return false;

        return true;
    }

    public int hashCode() {
        int result = 0;
        result = (pname != null ? pname.hashCode() : 0);
        result = 31 * result + (orgid != null ? orgid.hashCode() : 0);

        return result;
    }

    public String toString() {
        StringBuffer sb = new StringBuffer(getClass().getSimpleName());

        sb.append(" [");
        sb.append("pid").append("='").append(getPid()).append("', ");
        sb.append("panme").append("='").append(getPname()).append("', ");
        sb.append("orgid").append("='").append(getOrgid()).append("', ");
        
        
        sb.append("]");
      
        return sb.toString();
    }

}
